#include<iostream>
using namespace std;
const int N = 110;
int arr[N][N];
int n, m;
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> arr[i][j];
		}
	}
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			cout << arr[n - j + 1][i] << " ";
		}
		cout << endl;
	}
	/*for (int i = 1; i <= n; i++) {
		for (int j = n; j >= 1; j--) {
			cout << arr[i][j] << " ";
		}
		cout << endl;
	}*/
	return 0;
}